<template>
  <div class="sysmadmin">
        <!-- <h2>系统管理员管理</h2> -->
        <div class="title">
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/sysout/sysoutshouye' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>用户管理</el-breadcrumb-item>
            <el-breadcrumb-item>系统管理员管理</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="header">
          <el-input @change="search" v-model="input" placeholder="请输入内容"></el-input>
          <el-button type="primary">查询</el-button>
          <el-button type="primary">添加</el-button>
        </div>
        <div class="wrapper">
          <el-table :data="tableData" style="width: 100%" border stripe height="700">
            <el-table-column type="selection" width="50"></el-table-column>
            <el-table-column prop="adminId" label="管理员id" width="80"></el-table-column>
            <el-table-column prop="adminName" label="管理员名" width="80"></el-table-column>
            <el-table-column prop="adminAccount" label="管理员账号"></el-table-column>
            <el-table-column prop="adminPwd" label="管理员密码"></el-table-column>
            <el-table-column prop="loginTime" label="登录时间"></el-table-column>
            <el-table-column label="操作" width="240">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  @click="handleClick(scope.row)">查看</el-button>
                <el-button
                  size="mini"
                  @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
              </template>
          </el-table-column>
          </el-table>
        </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    name:'SysMadmin',
    data() {
      return {
        input: "",
        tableData: [],
        allData:[]
      };
    },
    created() {
      this.getAlladminlist()
    },
    mounted() {
      // this.getAlladminlist()
    },
    methods: {
      
      // 获取所有管理员
        getAlladminlist(){
            axios.get("http://localhost:8080/api/getAllAdmin/getAllAdminlist",{
              params:{
                id:1
              }
            }).then(
              res=>{
                // this.tableData = res.data
                // console.log("999",res)
                // console.log(this.tableData)
                for(var i= 0;i<res.data.length;i++){
                    var tem = Number(String(res.data[i].loginTime).slice(11,13))+8
                    var d = tem%24 > 10? tem%24 :'0'+tem%24
                    res.data[i].loginTime = String(res.data[i].loginTime).slice(0,10)+ ' ' +d + String(res.data[i].loginTime).slice(13,19)
                    // state.usersubgoods.push(value [i])
                    this.allData = res.data
                    this.tableData = this.allData
                }
              },
              error=>{
                console.log("88",error.message)
              }
            )
        },
        // 编辑事件
        handleEdit(){

        },
        // 查看事件
        handleClick(){

        },
        // 查找事件
        search(val){
          console.log("搜索了----",val,this.allData[0].userId)
          this.tableData = []
          if(val == ' '){
            this.tableData = this.allData
          }else{
            for(var i=0;i<this.allData.length;i++){
              if(this.allData[i].adminName.indexOf(val) !==-1){
              // if(this.allData[i].goodsName.indexOf(val) !==-1){
                this.tableData.push(this.allData[i])
              }
            }
            if(this.tableData == ''){
              alert("未找到你想要搜索的竞拍商品")
            }
          }
          console.log("查询结果为",this.tableData)
        }
    },
}
</script>

<style lang='less' scoped>
.sysmadmin{
  margin: 20px;
  width: 100%;

    .title{
      width: 95%;
      padding: 10px;
      background: #fff;
      border: 1px solid #eee;
      margin-bottom: 20px;
    }
    .header {
      display: flex;
      margin-bottom: 10px;
      button {
        margin-left: 20px;
      }
    }
}
</style>